
{% extends 'blog/base.html' %}
{% load static %}
{% load blog_tags %}

{% block title %} {{ article.title }} {% endblock %}

{% block extra_head %}
    <link rel="stylesheet" href="{% static 'css/code.css' %}">
    <script>
        hljs.initHighlightingOnLoad();
    </script>
{% endblock %}

{% block main %}
    {% if article %}
        <h1>{{ article.title }}</h1>
        <div>
            <span class="mr-1">
                分类:
                <a href="{% url 'blog:category-list' article.category.id %}">{{ article.category.name }}</a>
                |
            </span>
            <span class="mr-1">创建时间: {{ article.create_time }} |</span>
            <span class="mr-1">pv/uv: {{ article.pv }}/{{ article.uv }}</span>
        </div>
        <hr/>
        <!--文章正文-->
        {{ article.content|custom_markdown|safe }}
    {% endif %}
    <hr/>
    <div class="comment">
        <form class="form-group" action="{% url 'blog:comment' %}" method="post">
            {% csrf_token %}
            <input name="target" type="hidden" value="{{ request.path }}"/>
            {{ comment_form }}
            <input type="submit" value="写好了！">
        </form>
        <!-- 评论列表 -->
        <ul class="list-group">
            {% for comment in comment_list %}
                <li class="list-group-item">
                    <div class="nickname">
                        <a href="{{ comment.website }}">{{ comment.website }}</a>
                        <span>{{ comment.create_time }}</span>
                    </div>
                    <div class="comment-content">
                        {{ comment.content }}
                    </div>
                </li>
            {% endfor %}
        </ul>
    </div>
{% endblock %}
